using System;
using System.IO;
using System.Reflection;

namespace AmazonBookLinker
{
  internal static class AssemblyInfo
  {
    internal static string Title
    {
      get
      {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes( typeof(AssemblyTitleAttribute), false );
        if ( attributes.Length > 0 )
        {
          AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
          if ( titleAttribute.Title != "" )
            return titleAttribute.Title;
        }
        return Path.GetFileNameWithoutExtension( Assembly.GetExecutingAssembly().CodeBase );
      }
    }

    internal static Version Version
    {
      get { return Assembly.GetExecutingAssembly().GetName().Version; }
    }

    internal static string Description
    {
      get
      {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes( typeof(AssemblyDescriptionAttribute), false );
        if ( attributes.Length == 0 )
          return "";
        return ((AssemblyDescriptionAttribute)attributes[0]).Description;
      }
    }

    internal static string ProductName
    {
      get
      {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes( typeof(AssemblyProductAttribute), false );
        if ( attributes.Length == 0 )
          return "";
        return ((AssemblyProductAttribute)attributes[0]).Product;
      }
    }

    internal static string Copyright
    {
      get
      {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes( typeof(AssemblyCopyrightAttribute), false );
        if ( attributes.Length == 0 )
          return "";
        return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
      }
    }

    internal static string Company
    {
      get
      {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes( typeof(AssemblyCompanyAttribute), false );
        if ( attributes.Length == 0 )
          return "";
        return ((AssemblyCompanyAttribute)attributes[0]).Company;
      }
    }
  }
}